<?php

define('KC_INDEX',True);

require_once '../global.php';

/**
	
	POST过来的参数有 ass、kname、tags、sign
	MD5(ass=[ass]&kname=[kname]&tags=[tags]{info['sign']}) == sign 当一致的时候，验证通过
*/
function king_def(){
	global $king;
	$king->access('portal_express');


	$listid=kc_post('listid');
	$ktitle=kc_post('ktitle');
	$ndate=kc_post('ndate');
	$kcontent=kc_post('kcontent');
	$kpath=kc_post('kpath');
	$tag=kc_post('tag');
	$dec=kc_post('dec');
	$keywords=kc_post('keywords');

  	if($oneimage=preg_match('/(<img([^>]*))( src=)(["\'])(.*?)\4(([^>]*)\/?>)/is',$kcontent,$oneimage_array)){
					$images=$oneimage_array[5];
					
	}


	





    if(!empty($ktitle)){
		if(empty($tag)){
		$tag = keywords_class::k_dangdang_fc($ktitle);
		}
		$_array=array(
			'listid' =>$listid,
			'ktitle' =>$ktitle,
			'nlastdate'  =>$ndate,
			'ndate'   =>$ndate,
			'kcontent' =>$kcontent,
			'kkeywords'=>$keywords,
			'kpath'=>'page-'.$listid.'-'.$kpath.'.html',
			'ktag'=>$tag,			
			'kdescription'=>$dec,
			'kimage'=>$images,
			'nshow'=>'0',
			);
		if($listid == '3'){
		$_array['k_author']=' ';
		$a=$king->db->insert("%s__article",$_array);

		}elseif($listid == '4'){

		$a=$king->db->insert("%s__zhuanti",$_array);
		
		}

	if(!empty($a)){

		echo "成功添加".$a;
		
	}




if(!empty($keywords) && $listid=='3' ){
				
					$data_k=explode(',',$keywords);
				
					foreach($data_k as $val){
									
									$array_k=explode(',',keywords_class::k_dangdang_fc($val));

											
											$_array_k=array(
												'ktitle'=>$val,
												'ktag'=>keywords_class::k_dangdang_fc($val),
												'ndate'=>time(),	
												'kname'=>keywords_class::length($val),
											);

										
											$kid_k=keywords_class::k_ins_key($_array_k);


											if(!empty($kid_k)){
												$arrid=keywords_class::k_ins_tag($array_k,$kid_k);
									
											}
								}
			
				}	


























	}




}



?>